<!--改单订单项列表-->
<template>
  <div class="">
    <el-form
      ref="saleCaseFormRef"
      :model="Form"
      label-position="left"
      label-width="1rem"
    >
      <sim-form :Form="Form" isbtn @queryMethods="getqryCustList"></sim-form>
    </el-form>
    <DicTable
      ref="carordertable"
      stripe
      highlight-current-row
      highlight-hover-row
      border
      header-row-class-name="header-row-class"
      row-class-name="ne-row-class"
      :columnData="carOrdertbs.tableColumns"
      :tableData="carOrdertbs.tableData"
      :loading="carOrdertbs.tableLoading"
      :currentPage="carOrdertbs.tablePage.page"
      :pageSize="carOrdertbs.tablePage.pageSize"
      :totalResult="carOrdertbs.tablePage.totalResult"
      :pager="true"
      @on-page-change="handlePageChange"
      @cell-click="Onrowclick"
    >
      <template #operation="{ row }">
        <div class="clearfix operation">
          <div class="position">
            <dic-popover :config="popConfig" :row="row"></dic-popover>
          </div>
        </div>
      </template>
      <template #custSoNumber="{ row }">
        <el-link type="primary">{{
          row.custSoNumber + "(" + row.orderItemSeq + ")"
        }}</el-link>
      </template>
      <template #orderDate="{ row }">
        <span v-if="row.reqOrderDate && row.reqOrderDate != ''">{{
          row.reqOrderDate ? row.reqOrderDate.split(" ")[0] : ""
        }}</span>
        <span v-else>{{
          row.orderDate ? row.orderDate.split(" ")[0] : ""
        }}</span>
      </template>
    </DicTable>
  </div>
</template>

<script>
import SimForm from "@/components/public/SimForm";
import DicPopover from "@/components/order/PopoVer";
import DicTable from "@/components/public/DicTable";
import CommonUtil from "@/utils/common";
import OrderService from "@/api/order/OrderService.js";
import { mapState, mapGetters } from "vuex";
export default {
  name: "DismListOrder",
  props: {},
  data() {
    return {
      Form: {
        /**
         * type类型
         *         jmIpt精确模糊 input
         *         Ipt普通 input
         *         select 选择框
         *
         */
        //订单流水号  待定 ，显示是受理流水
        //IDC群号
        accNum: {
          type: "Ipt",
          cName: "设备号",
          cValue: "",
        },
      },

      // 订单order列表
      carOrdertbs: {
        tableColumns: [
          { type: "checkbox", width: 50 },
          { slotName: "custSoNumber", title: "流水号", width: 160 },
          { field: "offerName", title: "销售品名称", width: 100 },
          {
            slotName: "operation",
            title: "操作",
            width: 100,
            headerAlign: "center",
            // fixed: "right",
          },
          { slotName: "orderDate", title: "要求完成时间", width: 150 },
          { field: "regionRange", title: "通达地点", width: 100 },
          { field: "serviceOfferName", title: "登记事项", width: 100 },
          { field: "accNum", title: "设备号", width: 100 },
          { field: "useCustName", title: "甲端用户名称", width: 100 },
          { field: "contactName", title: "甲端联系人", width: 100 },
          { field: "mobilePhone", title: "甲端联系人电话", width: 100 },
          { field: "addressDesc", title: "甲端装机地址", width: 100 },
          { field: "zUseCustName", title: "乙端用户名称", width: 100 },
          { field: "zContactName", title: "乙端联系人", width: 100 },
          { field: "zMobilePhone", title: "乙端联系人电话", width: 100 },
          { field: "zAddressDesc", title: "乙端装机地址", width: 100 },
          { field: "rate", title: "速率", width: 100 },
        ],
        tableData: [],
        tableLoading: false,
        tablePage: {
          currentPage: 1,
          pageSize: 10,
          totalResult: 0,
        },
      },

      //服务弹窗配置
      popConfig: {
        modType: "50200002",
        name: "改单",
        placement: "bottom", //弹窗位置
        title: "", //弹窗标题
        width: "350", //弹窗宽度
        trigger: "click", //弹窗弹出方式 click/focus/hover/manual
        content: "", //弹窗内容
        // row:'',//表格行数据
        gutter: 10, //标签之间间隔
        span: 12, //每行标签个数，一行按24等分，12表示2个
      },
    };
  },
  computed: {
    ...mapState("orders", ["orderPosInfo", "CARRY_ROW"]),
    ...mapState("user", ["user"]),
    ...mapGetters(["orderPosInfochange"]),
  },
  components: {
    DicTable,
    SimForm,
    DicPopover,
  },
  created() {},
  watch: {
    CARRY_ROW: function () {
      this.getqryCustList();
    },
  },
  mounted() {
    this.getqryCustList();
    
    
  },
  methods: {
    // 查询列表
    async getqryCustList() {
      this.carOrdertbs.tableLoading = true;
      let msJson = {
        statusCds: "300098", //订单状态
        custSoNumber: this.CARRY_ROW.custSoNumber, //流水号  从上个页面带回
        handleOrgId: this.user.orgId,
        custId: this.orderPosInfo.custId || "204",
        batchNbr: "", //批次号
        accNum: "", //设备号,没有不传
      };
      let param = CommonUtil.paramsFun(
        1,
        this.Form,
        "pageIndex",
        this.carOrdertbs.tablePage.currentPage,
        this.carOrdertbs.tablePage.pageSize
      );
      const result = await OrderService.qryOrderItem({
        ...msJson,
        ...param,
      });
      this.carOrdertbs.tableLoading = false;
      
      
      if (result.code === 200 && result.meta.offerOrderItems) {
        this.carOrdertbs.tableData = result.meta.offerOrderItems;
        this.carOrdertbs.tablePage.currentPage = JSON.parse(
          result.meta.pageInfo.pageIndex
        );
        this.carOrdertbs.tablePage.totalResult = JSON.parse(
          result.meta.pageInfo.rowCount
        );
      } else {
        this.$message({
          type: "error",
          message: "请求失败!" + result.meta.msg,
        });
      }
    },
    handlePageChange({ currentPage, pageSize }) {
      this.custbs.tablePage.currentPage = currentPage;
      this.custbs.tablePage.pageSize = pageSize;
      this.getqryCustList();
    },
    Onrowclick(data) {
      //跳转产品详情
      
      if (data.column.title == "流水号") {
        
        sessionStorage.setItem("changeRow", JSON.stringify(data.row));
        const ppmCondition = {
          productId: data.row.prodId ? data.row.prodId : 80008007,
          serviceOfferId: "4010100000",
          modType: "50200003",
          optionId: "313", //需求单审核前后/订单审核前后/产品实例库  310，311，312，313，314
        };
        sessionStorage.setItem("ppmCondition", JSON.stringify(ppmCondition));
        sessionStorage.setItem("detailCondition", JSON.stringify(ppmCondition)); //解决详情刷新缓存请求条件被覆盖问题
        window.open("orders.html?router=productinfo", "_blank");
      }
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .vxe-table--render-default .vxe-body--column:not(.col--ellipsis),
.vxe-table--render-default .vxe-footer--column:not(.col--ellipsis) {
  padding: 0.05rem !important;
}
.radio-mt {
  margin-top: 0.1rem;
}
.select-box {
  width: 1rem;
  padding: 0;
}
.ne-operation-a {
  color: $blue;
  &:hover {
    text-decoration: underline;
    color: $blue;
  }
}

.operation {
  width: 100%;
  padding: 0 10px !important;
  height: 0.34rem;
  box-sizing: border-box;
  position: absolute;
  top: 20%;
  left: 0;
  .position {
    width: 100%;
    height: 100%;
    /*position: absolute;*/
    /*top: 0;*/
    /*left: 0;*/
    position: relative;
    text-align: center;
  }
}
</style>
